package Demo.demo20;

public class 日历 {
    public static void main(String[] args) {
        System.out.println("日\t一\t二\t三\t四\t五\t六");
        for (int i =1;i<=31;i++){
            System.out.print(i+"\t");
            if (i%7==0){
                System.out.println( );
            }
        }

        //求出前一个月空出来几天
        System.out.println("\n=============\n");
          int temp2 = 31 % 7;
        //把上个月份的位置空出来
        System.out.println("日\t一\t二\t三\t四\t五\t六");
        for (int i=1; i<=temp2; i++){
            System.out.print("\t");
        }
        //打印出二月日期
        for (int i =1;i<=28;i++){
            System.out.print(i+"\t");
            if ((31+i)%7==0){
                System.out.println( );
            }
        }


        //求出前一个月空出来几天
        System.out.println("\n=============\n");
        int temp3 = (28+31) % 7;
        //把上个月份的位置空出来
        System.out.println("日\t一\t二\t三\t四\t五\t六");
        for (int i=1; i<=temp3; i++){
            System.out.print("\t");
        }

        //打印出三月日期
        for (int i =1;i<=31;i++){
            System.out.print(i+"\t");
            if ((31+28+i)%7==0){
                System.out.println( );
            }
        }

        System.out.println("\n====================");
        System.out.println("日\t一\t二\t三\t四\t五\t六");
        int temp4 =(31+28+31)%7;
        for (int i = 1;i<=temp4;i++){
            System.out.print("\t");
        }

        for (int i =1;i<=30;i++){
            System.out.print(i+"\t");
            if ((31+28+31+i)%7==0){
                System.out.println( );
            }
        }
    }
}
